package com.lab.logtrack;

/**
 * Created by ak
 */
public class AppLog {
    /**
     * log输出
     */
    private static Logger mLogger;

    /**
     * 初始化输出类
     * @param logger
     */
    public static void initLogger(Logger logger) {
        mLogger = logger;
    }

    /**
     * 错误日志
     * @param paramString
     */
    public static void e(String paramString) {
        if (mLogger != null) {
            mLogger.e(paramString);
        }
    }

    public static void e(String tag,String msg){
        e(tag+":"+msg);
    }
    public static void d(String tag,String msg){
        d(tag+":"+msg);
    }
    public static void v(String tag,String msg){
        v(tag+":"+msg);
    }
    public static void i(String tag,String msg){
        i(tag+":"+msg);
    }

    /**
     * 错误日志
     * @param paramString
     * @param paramThrowable
     */
    public static void e(String paramString, Throwable paramThrowable) {
        if (mLogger != null) {
            mLogger.e(paramString, paramThrowable);
        }
    }

    public static void e(Throwable paramThrowable) {
        ef("%s:%s",paramThrowable.getMessage(),paramThrowable.getMessage());
    }

    public static void df(String temp, Object... args) {
        d(String.format(temp, args));
    }

    public static void ef(String temp, Object... args) {
        e(String.format(temp, args));
    }

    public static void vf(String temp, Object... args) {
        v(String.format(temp, args));
    }

    /**
     * 警告日志
     * @param paramString
     */
    public static void w(String paramString) {
        if (mLogger != null) {
            mLogger.w(paramString);
        }
    }

    public static void w(String tag ,String msg){
        w(tag+":"+msg);
    }

    /**
     * ⚠日志
     * @param paramString
     * @param paramThrowable
     */
    public static void w(String paramString, Throwable paramThrowable) {
        if (mLogger != null) {
            mLogger.w(paramString, paramThrowable);
        }
    }

    /**
     * info日志
     * @param paramString
     */
    public static void i(String paramString) {
        if (mLogger != null) {
            mLogger.i(paramString);
        }
    }

    /**
     * info日志
     * @param paramString
     * @param paramThrowable
     */
    public static void i(String paramString, Throwable paramThrowable) {
        if (mLogger != null) {
            mLogger.i(paramString, paramThrowable);
        }
    }

    /**
     * debug日志
     * @param paramString
     */
    public static void d(String paramString) {
        if (mLogger != null) {
            mLogger.d(paramString);
        }
    }

    /**
     * debug日志
     * @param paramString
     * @param paramThrowable
     */
    public static void d(String paramString, Throwable paramThrowable) {
        if (mLogger != null) {
            mLogger.d(paramString, paramThrowable);
        }
    }

    /**
     * verbose日志
     * @param paramString
     */
    public static void v(String paramString) {
        if (mLogger != null) {
            mLogger.v(paramString);
        }
    }
    /**
     * verbose日志
     * @param paramString
     */
    public static void v(String paramString, Throwable paramThrowable) {
        if (mLogger != null) {
            mLogger.v(paramString, paramThrowable);
        }
    }

    public static boolean isLogging(){
        return mLogger!=null&&mLogger.isDebug();
    }
}
